package com.itwenke.springbootdemo.shirosimple.demo;

import com.itwenke.springbootdemo.shirosimple.entity.BankAccount;
import com.itwenke.springbootdemo.shirosimple.service.IBankAccountService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Component
public class PrivateMethodDemo {

    @Resource
    private IBankAccountService bankAccountService;

    @Transactional(rollbackFor = Exception.class)
//    public void addBankAccount(BankAccount bankAccount) throws Exception {
    private void addBankAccount(BankAccount bankAccount) throws Exception {
        bankAccountService.addBankAccount(bankAccount);
        throw new Exception("测试事务回滚");
    }
}
